#include "GY_GraphicsCornerStyleRectItem.h"
#include <QDebug>
#include <QtMath>

GY_GraphicsCornerStyleRectItem::GY_GraphicsCornerStyleRectItem(const QString &guid, QGraphicsItem *parent)
    :GY_BasicsGraphicsObject(guid,this,parent)
{
    //图元类型
    GY_Object::setUserData(GY_ENUM::ClassType,QVariant("CornerStyleRect"));
    initializationPropertyInfo();
    this->setEditPointF("Point",m_PropertyInfoMap["Point"].propertyValue.toPointF());
    this->setCenterPointF(m_PropertyInfoMap["Position"].propertyValue.toPointF());
    updatePath();
}

void GY_GraphicsCornerStyleRectItem::initializationPropertyInfo()
{
    GY_PropertyInfo ObjectName(this);
    ObjectName.propertyName = "ObjectName";
    ObjectName.propertyValue = QString();
    ObjectName.updateType = Update|OrdinaryAttributes;
    ObjectName.propertyType = QStringPropertyType;
    ObjectName.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateObjectName;
    m_PropertyInfoMap.insert("ObjectName",ObjectName);
    m_PropertyInfoMap["ObjectName"].setConnect();

    GY_PropertyInfo IsVisible(this);
    IsVisible.propertyName = "IsVisible";
    IsVisible.propertyValue = true;
    IsVisible.updateType = Update|OrdinaryAttributes;
    IsVisible.propertyType = BoolPropertyType;
    IsVisible.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateIsVisible;
    m_PropertyInfoMap.insert("IsVisible",IsVisible);
    m_PropertyInfoMap["IsVisible"].setConnect();

    GY_PropertyInfo IsOutLined(this);
    IsOutLined.propertyName = "IsOutlined";
    IsOutLined.propertyValue = true;
    IsOutLined.updateType = Update|OrdinaryAttributes;
    IsOutLined.propertyType = BoolPropertyType;
    IsOutLined.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateIsOutLined;
    m_PropertyInfoMap.insert("IsOutlined",IsOutLined);
    m_PropertyInfoMap["IsOutlined"].setConnect();

    GY_PropertyInfo IsFilled(this);
    IsFilled.propertyName = "IsFilled";
    IsFilled.propertyValue = true;
    IsFilled.updateType = Update|OrdinaryAttributes;
    IsFilled.propertyType = BoolPropertyType;
    IsFilled.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateIsFilled;
    m_PropertyInfoMap.insert("IsFilled",IsFilled);
    m_PropertyInfoMap["IsFilled"].setConnect();

    GY_PropertyInfo IsAntialiased(this);
    IsAntialiased.propertyName = "IsAntialiased";
    IsAntialiased.propertyValue = true;
    IsAntialiased.updateType = Update|OrdinaryAttributes;
    IsAntialiased.propertyType = BoolPropertyType;
    IsAntialiased.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateIsAntialiased;
    m_PropertyInfoMap.insert("IsAntialiased",IsAntialiased);
    m_PropertyInfoMap["IsAntialiased"].setConnect();

    GY_PropertyInfo FillAttributes(this);
    FillAttributes.propertyName = "FillAttributes";
    FillAttributes.propertyValue = false;
    FillAttributes.updateType = Update|OrdinaryAttributes;
    FillAttributes.propertyType = BoolPropertyType;
    FillAttributes.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateFillAttributes;
    m_PropertyInfoMap.insert("FillAttributes",FillAttributes);
    m_PropertyInfoMap["FillAttributes"].setConnect();

    GY_PropertyInfo FillStyle(this);
    FillStyle.propertyName = "FillStyle";
    FillStyle.propertyValue = false;
    FillStyle.updateType = Update|OrdinaryAttributes;
    FillStyle.propertyType = FillStylePropertyType;
    FillStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateFillStyle;
    m_PropertyInfoMap.insert("FillStyle",FillStyle);
    m_PropertyInfoMap["FillStyle"].setConnect();

    GY_PropertyInfo FillColor(this);
    FillColor.propertyName = "FillColor";
    FillColor.propertyValue = QColor();
    FillColor.updateType = Update|OrdinaryAttributes;
    FillColor.propertyType = ColorPropertyType;
    FillColor.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateFillColor;
    m_PropertyInfoMap.insert("FillColor",FillColor);
    m_PropertyInfoMap["FillColor"].setConnect();

    GY_PropertyInfo FillGradient(this);
    FillGradient.propertyName = "FillGradient";
    FillGradient.propertyValue = QVariant();
    FillGradient.updateType = Update|OrdinaryAttributes;
    FillGradient.propertyType = FillGradientPropertyType;
    FillGradient.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateFillGradient;
    m_PropertyInfoMap.insert("FillGradient",FillGradient);
    m_PropertyInfoMap["FillGradient"].setConnect();

    GY_PropertyInfo Pattern(this);
    Pattern.propertyName = "Pattern";
    Pattern.propertyValue = QVariant();
    Pattern.updateType = Update|OrdinaryAttributes;
    Pattern.propertyType = PatternPropertyType;
    Pattern.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updatePattern;
    m_PropertyInfoMap.insert("Pattern",Pattern);
    m_PropertyInfoMap["Pattern"].setConnect();

    GY_PropertyInfo FillOpacity(this);
    FillOpacity.propertyName = "FillOpacity";
    FillOpacity.propertyValue = qreal(1);
    FillOpacity.updateType = Update|OrdinaryAttributes;
    FillOpacity.propertyType = QrealPropertyType;
    FillOpacity.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateFillOpacity;
    m_PropertyInfoMap.insert("FillOpacity",FillOpacity);
    m_PropertyInfoMap["FillOpacity"].setConnect();

    GY_PropertyInfo PenAttributes(this);
    PenAttributes.propertyName = "PenAttributes";
    PenAttributes.propertyValue = false;
    PenAttributes.updateType = Update|OrdinaryAttributes;
    PenAttributes.propertyType = BoolPropertyType;
    PenAttributes.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updatePenAttributes;
    m_PropertyInfoMap.insert("PenAttributes",PenAttributes);
    m_PropertyInfoMap["PenAttributes"].setConnect();

    GY_PropertyInfo PenColor(this);
    PenColor.propertyName = "PenColor";
    PenColor.propertyValue = QColor(255,255,255);
    PenColor.updateType = Update|OrdinaryAttributes;
    PenColor.propertyType = ColorPropertyType;
    PenColor.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updatePenColor;
    m_PropertyInfoMap.insert("PenColor",PenColor);
    m_PropertyInfoMap["PenColor"].setConnect();

    GY_PropertyInfo LineStyle(this);
    LineStyle.propertyName = "LineStyle";
    LineStyle.propertyValue = QVariant();
    LineStyle.updateType = Update|OrdinaryAttributes;
    LineStyle.propertyType = LineStylePropertyType;
    LineStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateLineStyle;
    m_PropertyInfoMap.insert("LineStyle",LineStyle);
    m_PropertyInfoMap["LineStyle"].setConnect();

    GY_PropertyInfo PenOpacity(this);
    PenOpacity.propertyName = "PenOpacity";
    PenOpacity.propertyValue = qreal(1);
    PenOpacity.updateType = Update|OrdinaryAttributes;
    PenOpacity.propertyType = QrealPropertyType;
    PenOpacity.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updatePenOpacity;
    m_PropertyInfoMap.insert("PenOpacity",PenOpacity);
    m_PropertyInfoMap["PenOpacity"].setConnect();

    //位置
    GY_PropertyInfo positonPropertyInfo(this);
    positonPropertyInfo.propertyName="Position";
    positonPropertyInfo.propertyValue=QPointF(0,0);
    positonPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateCirlePoint;
    positonPropertyInfo.propertyType=PropertyType::PointPropertyType;
    positonPropertyInfo.updateType=PropertyUpdateType::PointOfRelative|PropertyUpdateType::MoveUpdate|PropertyUpdateType::Update;
    m_PropertyInfoMap.insert(positonPropertyInfo.propertyName,positonPropertyInfo);
    m_PropertyInfoMap[positonPropertyInfo.propertyName].setConnect();

    //更新点位置,相对中心点
    GY_PropertyInfo sizePropertyInfo(this);
    sizePropertyInfo.propertyName="Size";
    sizePropertyInfo.propertyValue=QPointF(50,50);
    sizePropertyInfo.updateType = Update|OrdinaryAttributes;
    sizePropertyInfo.propertyType = PointPropertyType;
    sizePropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateSize;
    m_PropertyInfoMap.insert(sizePropertyInfo.propertyName,sizePropertyInfo);
    m_PropertyInfoMap[sizePropertyInfo.propertyName].setConnect();

    GY_PropertyInfo pointPropertyInfo(this);
    pointPropertyInfo.propertyName="Point";
    pointPropertyInfo.propertyValue=QPointF(50,50);
    pointPropertyInfo.updateType = NotUpdate;
    pointPropertyInfo.propertyType = PointPropertyType;
    pointPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updatePoint;
    m_PropertyInfoMap.insert(pointPropertyInfo.propertyName,pointPropertyInfo);
    m_PropertyInfoMap[pointPropertyInfo.propertyName].setConnect();

    GY_PropertyInfo cornerRadius(this);
    cornerRadius.propertyName="CornerRadius";
    cornerRadius.propertyValue=qreal(10.0);
    cornerRadius.updateType = Update|OrdinaryAttributes;
    cornerRadius.propertyType = QrealPropertyType;
    cornerRadius.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateCornerRadius;
    m_PropertyInfoMap.insert("CornerRadius",cornerRadius);
    m_PropertyInfoMap["CornerRadius"].setConnect();

    GY_PropertyInfo BottomLeftCornerStyle(this);
    BottomLeftCornerStyle.propertyName = "BottomLeftCornerStyle";
    BottomLeftCornerStyle.propertyValue = QString("ROUND");
    BottomLeftCornerStyle.updateType = Update|OrdinaryAttributes;
    BottomLeftCornerStyle.propertyType = QStringPropertyType;
    BottomLeftCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateCornerStyle;
    m_PropertyInfoMap.insert("BottomLeftCornerStyle",BottomLeftCornerStyle);
    m_PropertyInfoMap["BottomLeftCornerStyle"].setConnect();

    GY_PropertyInfo TopLeftCornerStyle(this);
    TopLeftCornerStyle.propertyName = "TopLeftCornerStyle";
    TopLeftCornerStyle.propertyValue = QString("ROUND");
    TopLeftCornerStyle.updateType = Update|OrdinaryAttributes;
    TopLeftCornerStyle.propertyType = QStringPropertyType;
    TopLeftCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateCornerStyle;
    m_PropertyInfoMap.insert("TopLeftCornerStyle",TopLeftCornerStyle);
    m_PropertyInfoMap["TopLeftCornerStyle"].setConnect();

    GY_PropertyInfo TopRightCornerStyle(this);
    TopRightCornerStyle.propertyName = "TopRightCornerStyle";
    TopRightCornerStyle.propertyValue = QString("ROUND");
    TopRightCornerStyle.updateType = Update|OrdinaryAttributes;
    TopRightCornerStyle.propertyType = QStringPropertyType;
    TopRightCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateCornerStyle;
    m_PropertyInfoMap.insert("TopRightCornerStyle",TopRightCornerStyle);
    m_PropertyInfoMap["TopRightCornerStyle"].setConnect();

    GY_PropertyInfo BottomRightCornerStyle(this);
    BottomRightCornerStyle.propertyName = "BottomRightCornerStyle";
    BottomRightCornerStyle.propertyValue = QString("ROUND");
    BottomRightCornerStyle.updateType = Update|OrdinaryAttributes;
    BottomRightCornerStyle.propertyType = QStringPropertyType;
    BottomRightCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRectItem::updateCornerStyle;
    m_PropertyInfoMap.insert("BottomRightCornerStyle",BottomRightCornerStyle);
    m_PropertyInfoMap["BottomRightCornerStyle"].setConnect();
}

void GY_GraphicsCornerStyleRectItem::updatePath()
{
    QPointF size = m_PropertyInfoMap["Size"].propertyValue.toPointF();

    //!画出图形路径
    QPainterPath path;
    //四个象限
    if(size.x()>=0) {
        //一象限
        if(size.y()>=0) {
            QString bottomLeftStyle = m_PropertyInfoMap["BottomLeftCornerStyle"].propertyValue.toString();
            QString topLeftStyle = m_PropertyInfoMap["TopLeftCornerStyle"].propertyValue.toString();
            QString topRightStyle = m_PropertyInfoMap["TopRightCornerStyle"].propertyValue.toString();
            QString bottomRightStyle = m_PropertyInfoMap["BottomRightCornerStyle"].propertyValue.toString();
            QPointF leftPoint = m_PropertyInfoMap["Position"].propertyValue.toPointF();
            updateQuadrantPath(path, bottomLeftStyle, topLeftStyle, topRightStyle, bottomRightStyle, leftPoint);
        }
        //四象限
        else {
            QString bottomLeftStyle = m_PropertyInfoMap["BottomLeftCornerStyle"].propertyValue.toString();
            QString topLeftStyle = m_PropertyInfoMap["TopLeftCornerStyle"].propertyValue.toString();
            QString topRightStyle = m_PropertyInfoMap["TopRightCornerStyle"].propertyValue.toString();
            QString bottomRightStyle = m_PropertyInfoMap["BottomRightCornerStyle"].propertyValue.toString();
            QPointF leftPoint = m_PropertyInfoMap["Position"].propertyValue.toPointF();
            updateQuadrantPath(path, topLeftStyle, bottomLeftStyle, bottomRightStyle, topRightStyle, QPointF(leftPoint.x(),leftPoint.y()-abs(size.y())));
        }
    }else {
        //二象限
        if(size.y()>=0) {
            QString bottomLeftStyle = m_PropertyInfoMap["BottomLeftCornerStyle"].propertyValue.toString();
            QString topLeftStyle = m_PropertyInfoMap["TopLeftCornerStyle"].propertyValue.toString();
            QString topRightStyle = m_PropertyInfoMap["TopRightCornerStyle"].propertyValue.toString();
            QString bottomRightStyle = m_PropertyInfoMap["BottomRightCornerStyle"].propertyValue.toString();
            QPointF leftPoint = m_PropertyInfoMap["Position"].propertyValue.toPointF();
            updateQuadrantPath(path, bottomRightStyle, topRightStyle, topLeftStyle, bottomLeftStyle, QPointF(leftPoint.x()-abs(size.x()),leftPoint.y()));
        }
        //三象限
        else {
            QString bottomLeftStyle = m_PropertyInfoMap["BottomLeftCornerStyle"].propertyValue.toString();
            QString topLeftStyle = m_PropertyInfoMap["TopLeftCornerStyle"].propertyValue.toString();
            QString topRightStyle = m_PropertyInfoMap["TopRightCornerStyle"].propertyValue.toString();
            QString bottomRightStyle = m_PropertyInfoMap["BottomRightCornerStyle"].propertyValue.toString();
            QPointF leftPoint = m_PropertyInfoMap["Position"].propertyValue.toPointF();
            updateQuadrantPath(path, topRightStyle, bottomRightStyle, bottomLeftStyle, topLeftStyle, QPointF(leftPoint.x()-abs(size.x()),leftPoint.y()-abs(size.y())));
        }
    }
    path.closeSubpath();
    this->setPath(path);
}

bool GY_GraphicsCornerStyleRectItem::updateCirlePoint(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=this->mapFromScene(value.toPointF());
    this->setCenterPointF(this->mapFromScene(value.toPointF()));
    this->setEditPointF("Point",this->mapFromScene(value.toPointF()+m_PropertyInfoMap["Size"].propertyValue.toPointF()));
    updatePath();
    return true;
}

bool GY_GraphicsCornerStyleRectItem::updatePoint(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    QPointF pf=this->mapFromScene(value.toPointF())-(m_PropertyInfoMap["Position"].propertyValue.toPointF());
    m_PropertyInfoMap["Size"].propertyValue = pf;
    this->setEditPointF(name,this->mapFromScene(value.toPointF()));
    updatePath();
    return true;
}

bool GY_GraphicsCornerStyleRectItem::updateSize(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    this->setEditPointF("Point",this->mapFromScene(value.toPointF()+this->mapToScene(m_PropertyInfoMap["Position"].propertyValue.toPointF())));
    updatePath();
    return true;
}

bool GY_GraphicsCornerStyleRectItem::updateCornerRadius(const QString &name, const QVariant &value)
{
    if(!value.canConvert<qreal>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    updatePath();
    return true;
}

bool GY_GraphicsCornerStyleRectItem::updateCornerStyle(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QString>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    updatePath();
    return true;
}

void GY_GraphicsCornerStyleRectItem::updateQuadrantPath(QPainterPath &path, const QString &bottomLeftStyle, const QString &topLeftStyle, const QString &topRightStyle, const QString &bottomRightStyle, const QPointF leftPoint)
{
    qreal radius = m_PropertyInfoMap["CornerRadius"].propertyValue.toReal();
    QPointF size = m_PropertyInfoMap["Size"].propertyValue.toPointF();
    //半径不得超过矩形框短边的一半
    qreal half = abs(abs(size.x())<abs(size.y())?size.x()/2:size.y()/2);
    //短边的一半
    if(radius>half) {
        radius = half;
    }
    //path移到起始点
    /*                2                3
     *                 ++++++++++++++++
     *                 +              +
     *                 +     起始点    +
     *    leftPoint -> @++++++##+++++++
     *                1                4
    */
    path.moveTo(leftPoint.x()+radius,leftPoint.y());
    //左下角
    cornerStyle(path,QPointF(leftPoint.x()+radius,leftPoint.y()),QPointF(leftPoint.x(),leftPoint.y()+radius)
                ,QPointF(leftPoint),QPointF(leftPoint.x()+radius,leftPoint.y()+radius),radius,bottomLeftStyle,270,-90,0,90);
    //左上角
    cornerStyle(path,QPointF(leftPoint.x(),leftPoint.y()+abs(size.y())-radius),QPointF(leftPoint.x()+radius,leftPoint.y()+abs(size.y()))
                ,QPointF(leftPoint.x(),leftPoint.y()+abs(size.y())),QPointF(leftPoint.x()+radius,leftPoint.y()+abs(size.y())-radius),radius,topLeftStyle,180,-90,270,90);
    //右上角
    cornerStyle(path,QPointF(leftPoint.x()+abs(size.x())-radius,leftPoint.y()+abs(size.y())),QPointF(leftPoint.x()+abs(size.x()),leftPoint.y()+abs(size.y())-radius)
                ,QPointF(leftPoint.x()+abs(size.x()),leftPoint.y()+abs(size.y())),QPointF(leftPoint.x()+abs(size.x())-radius,leftPoint.y()+abs(size.y())-radius),radius,topRightStyle,90,-90,180,90);
    //右下角
    cornerStyle(path,QPointF(leftPoint.x()+abs(size.x()),leftPoint.y()+radius),QPointF(leftPoint.x()+abs(size.x())-radius,leftPoint.y())
                ,QPointF(leftPoint.x()+abs(size.x()),leftPoint.y()),QPointF(leftPoint.x()+abs(size.x())-radius,leftPoint.y()+radius),radius,bottomRightStyle,0,-90,90,90);
}

void GY_GraphicsCornerStyleRectItem::cornerStyle(QPainterPath &path, const QPointF &startPoint, const QPointF &endPoint, const QPointF &outPoint, const QPointF &intPoint, const qreal radius, const QString &style, const qreal intStart, const qreal intEnd, const qreal outStart, const qreal outEnd)
{
    //上次path连接到本次路径开始点
    path.lineTo(startPoint);

//    if(style == "INVERTED_ROUND") {              //+radius左上点为矩形
//        path.arcTo(outPoint.x()-radius,outPoint.y()-radius,2*radius,2*radius,precalculatedAngle(outPoint,startPoint)
//                   ,precalculatedAngle(outPoint,endPoint)-precalculatedAngle(outPoint,startPoint));
//    }else if(style == "INVERTED_SQUARE") {
//        path.lineTo(intPoint);
//        path.lineTo(endPoint);
//    }else if(style == "MITER") {
//        path.lineTo(endPoint);
//    }else if(style == "ROUND") {
//        //内圆结束点为弧线开始位置
//        path.arcTo(intPoint.x()-radius,intPoint.y()-radius,2*radius,2*radius,precalculatedAngle(intPoint,endPoint)
//                   ,precalculatedAngle(intPoint,startPoint)-precalculatedAngle(intPoint,endPoint));
//        qDebug()<<precalculatedAngle(intPoint,endPoint)<<precalculatedAngle(intPoint,startPoint)-precalculatedAngle(intPoint,endPoint);
//    }else if(style == "SQUARE") {
//        path.lineTo(outPoint);
//        path.lineTo(endPoint);
//    }

    if(style == "INVERTED_ROUND") {
        path.arcTo(outPoint.x()-radius,outPoint.y()-radius,2*radius,2*radius,-outStart,-outEnd);
    }else if(style == "INVERTED_SQUARE") {
        path.lineTo(intPoint);
        path.lineTo(endPoint);
    }else if(style == "MITER") {
        path.lineTo(endPoint);
    }else if(style == "ROUND") {
        //内圆结束点为弧线开始位置
        path.arcTo(intPoint.x()-radius,intPoint.y()-radius,2*radius,2*radius,-intStart,-intEnd);
    }else if(style == "SQUARE") {
        path.lineTo(outPoint);
        path.lineTo(endPoint);
    }
}

qreal GY_GraphicsCornerStyleRectItem::precalculatedAngle(const QPointF &centerPoint, const QPointF &calculatePoint)
{
    //基于圆心的偏移坐标
    QPointF diffPoint=calculatePoint-centerPoint;
    qreal pointAngle=qRadiansToDegrees(qAtan2(diffPoint.y(),diffPoint.x()));
    if(diffPoint.y()<0)
    {
        pointAngle+=360;
    }
    return pointAngle;
}





